package com.esa.servlet.course;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esa.dbi.impl.CourseDBImpl;
import com.esa.javabean.Course;


public class ShowCourseByCnoServlet extends HttpServlet {
	public void doGet(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		response.setContentType("text/html");
		//response.setCharacterEncoding("utf-8");
		PrintWriter out=response.getWriter();
		this.doPost(request, response);
		out.flush();
		out.close();
	}
	
	public void doPost(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		
		String  cno=request.getParameter("cno");
		String code=request.getParameter("code");
		CourseDBImpl cdbi=new CourseDBImpl();
		Course course=new Course();
		course=cdbi.getCourseByCno(cno);
		//System.out.println("ShowUserByIdServlet line 30.....");
		request.setAttribute("course",course);
		//request.setCharacterEncoding("utf-8");
		String acname=(String)request.getSession().getAttribute("acname");
		request.setAttribute("acname",acname);
		if(code.equals("show")){
			request.getRequestDispatcher("showUserManager.jsp").forward(request, response);
		}else if(code.equals("update")){
			request.getRequestDispatcher("updateCourse.jsp").forward(request, response);
		}
		
		out.flush();
		out.close();
	}
}
